package com.elitel.frame.business.service.impl;

import com.elitel.common.CustomHttpServletRequestWrapper;
import com.elitel.common.utils.SpringUtils;
import com.elitel.frame.base.service.SysPrjServiceService;
import com.elitel.frame.business.service.PolymerServerService;
import com.elitel.frame.business.service.common.exception.ServerRequestException;
import com.elitel.frame.business.service.common.impl.CommonServerExecutor;
import com.elitel.frame.main.dao.BaseServicesMapper;
import com.elitel.frame.main.dao.polym.CfgMultQueryFieldMapper;
import com.elitel.frame.main.dao.polym.CfgMultRelationFieldMapper;
import com.elitel.frame.main.dao.polym.CfgMultRelationMapper;
import com.elitel.frame.main.dao.polym.CfgMultResultFieldMapper;
import com.elitel.frame.main.entity.BaseServices;
import com.elitel.frame.main.entity.SysPrjservice;
import com.elitel.frame.main.entity.enums.PolymerConcatColumnStrategyEnum;
import com.elitel.frame.main.entity.enums.PolymerJoinEnum;
import com.elitel.frame.main.entity.polym.*;
import com.elitel.frame.main.entity.vo.JsonDataResult;
import com.elitel.frame.main.entity.vo.PageResponseVo;
import lombok.Data;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.stream.Collectors;

import static com.elitel.common.core.constant.RequestConstant.SERVICE_ID;
import static com.elitel.frame.main.entity.constant.CommonApiUrl.COMMON_API;

/**
 * 聚合服务核心处理类
 *
 * @author hi_bj
 */
@Service
public class PolymerServerServiceImpl implements PolymerServerService {
    private final static Log logger = LogFactory.getLog(PolymerServerServiceImpl.class);
    private final static String JSON_DATA_RESULT2 = "jsonDataResult2";
    private final static String JSON_DATA_RESULT1 = "jsonDataResult1";
    public final static String POLYMER_PARAM = "polymerParam";
    public final static String POLYMER = "polymer";

    @Autowired
    WebApplicationContext webApplicationContext;
    @Autowired
    SysPrjServiceService sysPrjServiceService;
    @Autowired
    CfgMultRelationMapper cfgMultRelationMapper;
    @Autowired
    private BaseServicesMapper baseServicesMapper;
    @Autowired
    CfgMultRelationFieldMapper cfgMultRelationFieldMapper;
    @Autowired
    CfgMultQueryFieldMapper cfgMultQueryFieldMapper;
    @Autowired
    CfgMultResultFieldMapper cfgMultResultFieldMapper;
    @Autowired
    private ThreadPoolTaskExecutor threadPoolTaskExecutor;

    @Override
    public PageResponseVo<Map<String, Object>> queryPolymerServer(HttpServletRequest request, String serviceId,
                                                                  String pageNO, String pageSize,
                                                                  String conQuery, String refCache) {
        //聚合参数
        PolymerQuery polymerQuery = new PolymerQuery();
        //1.参数参数初始化
        initPolymerQueryValue(polymerQuery, request, serviceId);
        //2.请求聚合服务
        requestService(polymerQuery);
        //3.处理服务返回结果
        handleReturnValue(polymerQuery);

        PageResponseVo<Map<String, Object>> pageResponse = new PageResponseVo<>();
        List<Map<String, Object>> resultList = polymerQuery.getResultList();
        pageResponse.setTotal(resultList.size());
        //逻辑分页
        int start = (Integer.parseInt(pageNO) - 1) * Integer.parseInt(pageSize);
        int end = Integer.parseInt(pageSize) * Integer.parseInt(pageNO);
        if (start > resultList.size()) {
            pageResponse.setRows(new ArrayList<>());
            return pageResponse;
        }
        pageResponse.setRows(resultList.subList(start, end > resultList.size() ? resultList.size() : end));
        return pageResponse;
    }

    @Override
    public List<CfgMultQueryField> selectQueryFiled(String serviceID) {
        SysPrjservice sysPrjservice = sysPrjServiceService.getSysPrjserviceByServiceCode(serviceID);
        //查询参数
        CfgMultQueryFieldExample cfgMultQueryFieldExample = new CfgMultQueryFieldExample();
        cfgMultQueryFieldExample.createCriteria().andServiceIdEqualTo(sysPrjservice.getGuid());
        List<CfgMultQueryField> queryFieldList = cfgMultQueryFieldMapper.selectByExample(cfgMultQueryFieldExample);
        return queryFieldList;
    }

    @Override
    public List<CfgMultResultField> selectShowFiled(String serviceID) {
        SysPrjservice sysPrjservice = sysPrjServiceService.getSysPrjserviceByServiceCode(serviceID);
        //查询参数
        CfgMultResultFieldExample cfgMultResultFieldExample = new CfgMultResultFieldExample();
        cfgMultResultFieldExample.createCriteria().andServiceIdEqualTo(sysPrjservice.getGuid());
        List<CfgMultResultField> resultFieldList = cfgMultResultFieldMapper.selectByExample(cfgMultResultFieldExample);
        return resultFieldList;
    }

    /**
     * 请求服务
     *
     * @param polymerQuery
     */
    private void requestService(PolymerQuery polymerQuery) {
        HttpServletRequest request = polymerQuery.getRequest();
        Map<String, String[]> parameterMap = request.getParameterMap();
        //服务1 httpServletRequest
        CustomHttpServletRequestWrapper httpServletRequest1 = new CustomHttpServletRequestWrapper(request);
        Map<String, String[]> parameterMap1 = httpServletRequest1.getParameterMap();
        parameterMap1.clear();
        //服务2 httpServletRequest
        CustomHttpServletRequestWrapper httpServletRequest2 = new CustomHttpServletRequestWrapper(request);
        Map<String, String[]> parameterMap2 = httpServletRequest2.getParameterMap();
        parameterMap2.clear();
        //处理查询参数
        for (CfgMultQueryField cfgMultQueryField : polymerQuery.getQueryList()) {
            if (parameterMap.containsKey(cfgMultQueryField.getNewFieldCode())) {
                if (polymerQuery.getServiceId1().equals(cfgMultQueryField.getSourceServiceId())) {
                    parameterMap1.put(cfgMultQueryField.getSourceFieldCode(), parameterMap.get(cfgMultQueryField.getNewFieldCode()));
                } else if (polymerQuery.getServiceId2().equals(cfgMultQueryField.getSourceServiceId())) {
                    parameterMap2.put(cfgMultQueryField.getSourceFieldCode(), parameterMap.get(cfgMultQueryField.getNewFieldCode()));
                }
            }
        }
        //获取服务数据
        try {
            // 异步获取结果集
            long start = System.currentTimeMillis();
            this.asynGetRes(httpServletRequest1, httpServletRequest2, polymerQuery);
            long end = System.currentTimeMillis();
            logger.error("聚合服务调用下层服务一共使用" + (end - start) + "毫秒");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void asynGetRes(CustomHttpServletRequestWrapper httpServletRequest1, CustomHttpServletRequestWrapper httpServletRequest2, PolymerQuery polymerQuery) {
        // 开启两个线程进行查询
        CountDownLatch countDownLatch = new CountDownLatch(2);
        threadPoolTaskExecutor.execute(() -> {
            try {
                String serviceUrl1 = polymerQuery.getServiceUrl1();
                if (COMMON_API.equals(serviceUrl1)) {
                    List rows = getRows(httpServletRequest1);                   
                    polymerQuery.setResultList1(rows);

                } else {
                    httpServletRequest1.setParameter(SERVICE_ID, polymerQuery.serviceCode1);
                    httpServletRequest1.setParameter(POLYMER_PARAM, POLYMER);
                    ServletRequestAttributes requestAttributes1 = new ServletRequestAttributes(httpServletRequest1);
                    RequestContextHolder.setRequestAttributes(requestAttributes1, true);
                    logger.warn("开始查询服务1的数据");
                    JsonDataResult jsonDataResult = (JsonDataResult) requestServiceData(httpServletRequest1, serviceUrl1, polymerQuery.getServiceCode1());
                    List rows = ((PageResponseVo) jsonDataResult.getData()).getRows();
                    polymerQuery.setResultList1(rows);
                    logger.warn("结束查询服务1的数据");
                }
            } catch (Exception e) {
                logger.error("查询服务1数据异常", e);
                throw new RuntimeException(e);
            } finally {
                // 计数器减1
                countDownLatch.countDown();
            }
        });

        threadPoolTaskExecutor.execute(() -> {
            try {
                String serviceUrl2 = polymerQuery.getServiceUrl2();
                if (COMMON_API.equals(serviceUrl2)) {
                    List rows = getRows(httpServletRequest1);
                    polymerQuery.setResultList1(rows);
                } else {
                    httpServletRequest2.setParameter(SERVICE_ID, polymerQuery.serviceCode2);
                    httpServletRequest2.setParameter(POLYMER_PARAM, POLYMER);
                    ServletRequestAttributes attributes2 = new ServletRequestAttributes(httpServletRequest2);
                    RequestContextHolder.setRequestAttributes(attributes2, true);
                    logger.warn("开始查询服务2的数据");
                    JsonDataResult jsonDataResult = (JsonDataResult) requestServiceData(httpServletRequest2, serviceUrl2, polymerQuery.getServiceCode2());
                    List rows = ((PageResponseVo) jsonDataResult.getData()).getRows();
                    polymerQuery.setResultList2(rows);
                    logger.warn("结束查询服务2的数据");
                }
            } catch (Exception e) {
                logger.error("查询服务2数据异常", e);
                throw new RuntimeException(e);
            } finally {
                countDownLatch.countDown();
            }
        });
        try {
            // 阻塞一下 保证之前的所有的线程都执行完成，才会走下面的；
            countDownLatch.await();
        } catch (Exception e) {
            logger.error("阻塞异常:" + e.getMessage());
        }
    }

    private List getRows(CustomHttpServletRequestWrapper httpServletRequest1) {

        Map<String, String[]> parameterMap = httpServletRequest1.getParameterMap();

        HashMap<String, Object> actualParam = new HashMap<>();
        parameterMap.forEach((k, v) -> {
            if (v != null) {
                if (v.length == 1) {
                    actualParam.put(k, v[0]);
                }
                if (v.length > 1) {
                    actualParam.put(k, v);
                }

            }
        });
        CommonServerExecutor bean = SpringUtils.getBean(CommonServerExecutor.class);
        Object resFromUrl;
        try {
            resFromUrl = bean.request(actualParam, httpServletRequest1, ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getResponse());
        } catch (ServerRequestException e) {
            throw new RuntimeException(e);
        }

        Object actRes = resFromUrl;
        if (resFromUrl instanceof JsonDataResult) {
            JsonDataResult jsonDataResult = (JsonDataResult) resFromUrl;
            actRes = jsonDataResult.getData();
        }

        List rows = new ArrayList();
        if (actRes instanceof PageResponseVo) {
            PageResponseVo pageResponseVo = (PageResponseVo) actRes;
            rows = pageResponseVo.getRows();
        }
        return rows;
    }

    /**
     * 获取服务数据
     *
     * @param request
     * @param serviceUrl
     * @param serviceId
     * @return
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     */
    private Object requestServiceData(HttpServletRequest request, String serviceUrl, String serviceId) throws InvocationTargetException, IllegalAccessException {
        HandlerMethod handlerMethod = null;
        RequestMappingHandlerMapping requestMappingHandlerMapping = webApplicationContext.getBean(RequestMappingHandlerMapping.class);
        // 获取 RequestMapping中的全部方法
        Map<RequestMappingInfo, HandlerMethod> handlerMethodMap = requestMappingHandlerMapping.getHandlerMethods();
        for (RequestMappingInfo requestMappingInfo : handlerMethodMap.keySet()) {
            //获取所有的URL
            Set<String> urlSet = requestMappingInfo.getPatternsCondition().getPatterns();
            if (!ObjectUtils.isEmpty(urlSet) && urlSet.contains(serviceUrl)) {
                handlerMethod = handlerMethodMap.get(requestMappingInfo);
                break;
            }
        }
        if (handlerMethod != null) {
            //获取当前Controller对应的 beanName
            String beanName = String.valueOf(handlerMethod.getBean());
            return handlerMethod.getMethod().invoke(webApplicationContext.getBean(beanName),
                    request, serviceId, "1", "10000", null, null);
        }
        return null;
    }

    /**
     * 处理服务结果
     *
     * @param polymerQuery
     * @return
     */
    public void handleReturnValue(PolymerQuery polymerQuery) {
        List<Map<String, Object>> resultList = new ArrayList<>();
        polymerQuery.setResultList(resultList);
        //显示字段分组
        Map<String, List<CfgMultResultField>> showListMap = polymerQuery.getShowList().stream()
                .collect(Collectors.groupingBy(CfgMultResultField::getNewFieldCode));
        if (PolymerJoinEnum.INNER_JOIN.equals(polymerQuery.getJoin())) {
            //服务1分组（按关联字段）
            Map<String, List<Map<String, Object>>> resultListMap = polymerQuery.getResultList1().stream()
                    .collect(Collectors.groupingBy(item -> concatGroupKey(item, polymerQuery.getRelationList(), polymerQuery.getServiceId1())));
            //遍历服务2
            for (Map<String, Object> dataMap : polymerQuery.getResultList2()) {
                String keys = concatGroupKey(dataMap, polymerQuery.getRelationList(), polymerQuery.getServiceId2());
                if (resultListMap.containsKey(keys)) {
                    //遍历服务1
                    for (Map<String, Object> tempMap : resultListMap.get(keys)) {
                        //处理新服务显示的数据列
                        resultList.add(handleColumn(showListMap, polymerQuery, tempMap, dataMap));
                    }
                }
            }
        } else if (PolymerJoinEnum.LEFT_JOIN.equals(polymerQuery.getJoin())) {
            //服务2分组（按关联字段）
            Map<String, List<Map<String, Object>>> resultListMap = polymerQuery.getResultList2().stream()
                    .collect(Collectors.groupingBy(item -> concatGroupKey(item, polymerQuery.getRelationList(), polymerQuery.getServiceId2())));
            //遍历服务1
            for (Map<String, Object> dataMap1 : polymerQuery.getResultList1()) {
                String keys = concatGroupKey(dataMap1, polymerQuery.getRelationList(), polymerQuery.getServiceId1());
                if (resultListMap.containsKey(keys)) {
                    for (Map<String, Object> dataMap2 : resultListMap.get(keys)) {
                        //处理新服务显示的数据列
                        resultList.add(handleColumn(showListMap, polymerQuery, dataMap1, dataMap2));
                    }
                } else {
                    resultList.add(handleColumn(showListMap, polymerQuery, dataMap1, null));
                }
            }

        } else if (PolymerJoinEnum.RIGHT_JOIN.equals(polymerQuery.getJoin())) {
            //服务1分组（按关联字段）
            Map<String, List<Map<String, Object>>> resultListMap = polymerQuery.getResultList1().stream()
                    .collect(Collectors.groupingBy(item -> concatGroupKey(item, polymerQuery.getRelationList(), polymerQuery.getServiceId1())));
            //遍历服务2
            for (Map<String, Object> dataMap2 : polymerQuery.getResultList2()) {
                String keys = concatGroupKey(dataMap2, polymerQuery.getRelationList(), polymerQuery.getServiceId2());
                if (resultListMap.containsKey(keys)) {
                    for (Map<String, Object> dataMap1 : resultListMap.get(keys)) {
                        resultList.add(handleColumn(showListMap, polymerQuery, dataMap1, dataMap2));
                    }
                } else {
                    resultList.add(handleColumn(showListMap, polymerQuery, null, dataMap2));
                }
            }
        } else if (PolymerJoinEnum.FULL_JOIN.equals(polymerQuery.getJoin())) {
            //服务1分组（按关联字段）
            Map<String, List<Map<String, Object>>> resultListMap = polymerQuery.getResultList1().stream()
                    .collect(Collectors.groupingBy(item -> concatGroupKey(item, polymerQuery.getRelationList(), polymerQuery.getServiceId1())));
            //有关联的Key集合
            Set<String> containsKeySet = new HashSet();
            //遍历服务2
            for (Map<String, Object> dataMap2 : polymerQuery.getResultList2()) {
                String keys = concatGroupKey(dataMap2, polymerQuery.getRelationList(), polymerQuery.getServiceId2());
                if (resultListMap.containsKey(keys)) {
                    for (Map<String, Object> dataMap1 : resultListMap.get(keys)) {
                        resultList.add(handleColumn(showListMap, polymerQuery, dataMap1, dataMap2));
                    }
                    containsKeySet.add(keys);
                } else {
                    resultList.add(handleColumn(showListMap, polymerQuery, null, dataMap2));
                }
            }
            //遍历剩余的服务1
            for (Map.Entry<String, List<Map<String, Object>>> dataMap : resultListMap.entrySet()) {
                if (!containsKeySet.contains(dataMap.getKey())) {
                    for (Map<String, Object> dataMap1 : dataMap.getValue()) {
                        resultList.add(handleColumn(showListMap, polymerQuery, dataMap1, null));
                    }
                }
            }
        }
    }

    /**
     * 处理服务的结果
     *
     * @param showListMap  显示字段的分组
     * @param polymerQuery 聚合查询参数
     * @param dataMap1     服务一
     * @param dataMap2     服务二
     * @return
     */
    private Map<String, Object> handleColumn(Map<String, List<CfgMultResultField>> showListMap, PolymerQuery polymerQuery,
                                             Map<String, Object> dataMap1, Map<String, Object> dataMap2) {
        Map<String, Object> resultMap = new HashMap<>();
        for (Map.Entry<String, List<CfgMultResultField>> entryMap : showListMap.entrySet()) {
            Object val1 = null, val2 = null;
            for (CfgMultResultField cfgMultResultField : entryMap.getValue()) {
                if (polymerQuery.getServiceId1().equals(cfgMultResultField.getSourceServiceId()) && dataMap1 != null) {
                    val1 = dataMap1.get(cfgMultResultField.getSourceFieldCode());
                } else if (polymerQuery.getServiceId2().equals(cfgMultResultField.getSourceServiceId()) && dataMap2 != null) {
                    val2 = dataMap2.get(cfgMultResultField.getSourceFieldCode());
                }
            }
            resultMap.put(entryMap.getKey(), getConcatColumnData(entryMap.getValue().get(0).getCondition(), val1, val2));
        }
        return resultMap;
    }

    /**
     * 获取拼接列数据
     *
     * @param strategyEnum 策略
     * @param val1         服务1值
     * @param val2         服务2值
     * @return
     */
    private Object getConcatColumnData(String strategyEnum, Object val1, Object val2) {
        if (PolymerConcatColumnStrategyEnum.LEFT.name().equals(strategyEnum)) {
            return val1;
        } else if (PolymerConcatColumnStrategyEnum.RIGHT.name().equals(strategyEnum)) {
            return val2;
        } else {
            if (val1 != null && val2 != null) {
                if (PolymerConcatColumnStrategyEnum.NOT_NULL_LEFT.name().equals(strategyEnum)) {
                    return val1;
                } else if (PolymerConcatColumnStrategyEnum.NOT_NULL_RIGHT.name().equals(strategyEnum)) {
                    return val2;
                }
            }
            if (val1 != null) {
                return val1;
            }
            if (val2 != null) {
                return val2;
            }
        }
        return null;
    }

    /**
     * 拼接分组后的Key
     *
     * @param dataMap       数据行
     * @param relationList  关联字段集合
     * @param typeServiceId 服务类型
     * @return
     */
    private String concatGroupKey(Map<String, Object> dataMap, List<CfgMultRelationField> relationList, String typeServiceId) {
        StringBuilder keys = new StringBuilder();
        for (CfgMultRelationField tempMap : relationList) {
            String key = null;
            if (typeServiceId.equals(tempMap.getFirstServiceId())) {
                key = tempMap.getFirstFieldCode();
            } else if (typeServiceId.equals(tempMap.getSecondServiceId())) {
                key = tempMap.getSecondFieldCode();
            }
            keys.append(String.valueOf(dataMap.get(key))).append("_");
        }
        return keys.deleteCharAt(keys.lastIndexOf("_")).toString();
    }


    /**
     * 处理参数初始化
     *
     * @param polymerQuery 参数
     * @param request      HttpServletRequest
     * @param serviceID    服务1
     */
    private void initPolymerQueryValue(PolymerQuery polymerQuery, HttpServletRequest request,
                                       String serviceID) {
        SysPrjservice sysPrjservice = sysPrjServiceService.getSysPrjserviceByServiceCode(serviceID);
        // 获取关联关系
        CfgMultRelationExample example = new CfgMultRelationExample();
        example.createCriteria().andServiceIdEqualTo(sysPrjservice.getGuid());
        List<CfgMultRelation> cfgMultRelations = cfgMultRelationMapper.selectByExample(example);
        CfgMultRelation cfgMultRelation = cfgMultRelations.get(0);
        String serviceId1 = cfgMultRelation.getFirstServiceId();
        String serviceId2 = cfgMultRelation.getSecondServiceId();
        //获取服务基本信息
        SysPrjservice sysPrjservice1 = sysPrjServiceService.getProjectConfigByGuid(serviceId1);
        SysPrjservice sysPrjservice2 = sysPrjServiceService.getProjectConfigByGuid(serviceId2);
        //获取服务访问配置信息
        BaseServices baseServices1 = baseServicesMapper.selectByPrimaryKey(sysPrjservice1.getServicetype());
        BaseServices baseServices2 = baseServicesMapper.selectByPrimaryKey(sysPrjservice2.getServicetype());
        //设置request参数
        polymerQuery.setRequest(request);
        polymerQuery.setServiceId1(serviceId1);
        polymerQuery.setServiceId2(serviceId2);
        polymerQuery.setServiceCode1(sysPrjservice1.getServicecode());
        polymerQuery.setServiceCode2(sysPrjservice2.getServicecode());
        polymerQuery.setServiceUrl1(baseServices1.getServiceurl());
        polymerQuery.setServiceUrl2(baseServices2.getServiceurl());

        //关联条件
        polymerQuery.setJoin(PolymerJoinEnum.valueOf(cfgMultRelation.getCondition()));

        //关联字段
        CfgMultRelationFieldExample cfgMultRelationFieldExample = new CfgMultRelationFieldExample();
        cfgMultRelationFieldExample.createCriteria().andServiceIdEqualTo(sysPrjservice.getGuid());
        List<CfgMultRelationField> relationList = cfgMultRelationFieldMapper.selectByExample(cfgMultRelationFieldExample);
        polymerQuery.setRelationList(relationList);

        //查询参数
        CfgMultQueryFieldExample cfgMultQueryFieldExample = new CfgMultQueryFieldExample();
        cfgMultQueryFieldExample.createCriteria().andServiceIdEqualTo(sysPrjservice.getGuid());
        List<CfgMultQueryField> queryList = cfgMultQueryFieldMapper.selectByExample(cfgMultQueryFieldExample);
        polymerQuery.setQueryList(queryList);

        //展示字段
        CfgMultResultFieldExample cfgMultResultFieldExample = new CfgMultResultFieldExample();
        cfgMultResultFieldExample.createCriteria().andServiceIdEqualTo(sysPrjservice.getGuid());
        List<CfgMultResultField> showList = cfgMultResultFieldMapper.selectByExample(cfgMultResultFieldExample);
        polymerQuery.setShowList(showList);
    }

    /**
     * 聚合参数
     */
    @Data
    class PolymerQuery {

        HttpServletRequest request;
        /**
         * 服务一  id
         */
        private String serviceId1;
        /**
         * 服务二  id
         */
        private String serviceId2;
        /**
         * 服务一  code
         */
        private String serviceCode1;
        /**
         * 服务二  code
         */
        private String serviceCode2;
        /**
         * 服务  关联条件
         */
        private PolymerJoinEnum join;
        /**
         * 服务  关联字段
         */
        private List<CfgMultRelationField> relationList;
        /**
         * 服务一 URL
         */
        private String serviceUrl1;
        /**
         * 服务二 URL
         */
        private String serviceUrl2;
        /**
         * 服务一 数据记录
         */
        private List<Map<String, Object>> resultList1;
        /**
         * 服务二  数据记录
         */
        private List<Map<String, Object>> resultList2;
        /**
         * 新服务查询条件
         */
        private List<CfgMultQueryField> queryList;
        /**
         * 新服务显示列
         */
        private List<CfgMultResultField> showList;

        /**
         * 新服务数据记录
         */
        private List<Map<String, Object>> resultList;

    }

    /**
     * 自定义 HttpServletRequest包装类
     */


}
